/* ================ 全局变量定义 ================ */
:root {
    --primary-color: #1890ff;
    --secondary-color: #722ed1;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --error-color: #ff4d4f;
    --heading-color: rgba(0, 0, 0, 0.85);
    --text-color: rgba(0, 0, 0, 0.65);
    --text-color-secondary: rgba(0, 0, 0, 0.45);
    --border-color: #f0f0f0;
    --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ================ 基础布局样式 ================ */
.layout {
    width: 100%;
    min-width: 1000px;
    height: 100%;
    border-radius: 8px;
    display: flex;
    background: #fff;

    :global {
        .ant-prompts {
            color: rgba(0, 0, 0, 0.88);
        }
    }

    /* 移动端适配 */
    @media screen and (max-width: 768px) {
        min-width: 100%;
        border-radius: 0;
        overflow: hidden;
    }
}

/* ================ 左侧菜单区域 ================ */
.menu {
    width: 280px;
    background: linear-gradient(180deg, #225a8f 0%, #318ae2 100%);
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 4px 0 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    overflow: hidden;
    z-index: 1000;

    &.collapsed {
        width: 64px;

        .logo {
            justify-content: center;
            padding: 0;

            img {
                margin-right: 0;
            }

            span {
                width: 0;
                opacity: 0;
                overflow: hidden;
            }
        }

        .addBtn {
            width: 40px;
            min-width: 40px;
            margin: 0 auto 16px;
            padding: 0;
            overflow: hidden;

            .btnText {
                display: none;
            }
        }

        :global(.ant-conversations .ant-conversations-item) {
            padding: 12px 8px;
            justify-content: center;

            .ant-conversations-label {
                width: 0;
                opacity: 0;
                overflow: hidden;
            }

            /* 确保只有悬停的元素才显示标题 */
            &:hover {
                .ant-conversations-label {
                    width: auto;
                    opacity: 1;
                    position: absolute;
                    left: 64px;
                    background: #3a6ea5;
                    padding: 8px 12px;
                    border-radius: 4px;
                    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
                    z-index: 10;
                    white-space: nowrap;
                    overflow: visible;
                    color: #fff;
                    min-width: 120px;
                    text-align: left;
                    /* 添加关键属性，修复显示错误 */
                    display: block;
                    transition: opacity 0.3s ease, transform 0.2s ease;
                    transform: translateX(0);
                }
            }

            /* 非悬停状态确保标题隐藏 */
            &:not(:hover) .ant-conversations-label {
                opacity: 0;
                width: 0;
                transform: translateX(-10px);
                display: none;
            }
        }
    }

    /* 移动端适配 */
    @media screen and (max-width: 768px) {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(0);

        &.collapsed {
            transform: translateX(-100%);

            /* 移动端展开按钮 */
            .expandBtn {
                display: flex;
                position: fixed;
                left: 8px;
                top: 50%;
                transform: translateY(-50%);
                width: 32px;
                height: 32px;
                background: #3a6ea5;
                border-radius: 50%;
                align-items: center;
                justify-content: center;
                box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
                cursor: pointer;
                z-index: 1001;
                color: #fff;
                transition: all 0.3s ease;

                &:hover {
                    background: #4a7eb5;
                    transform: translateY(-50%) scale(1.05);
                }

                .anticon {
                    font-size: 16px;
                }
            }
        }
    }
}

/* Logo 区域 */
.logo {
    display: flex;
    height: 60px;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    box-sizing: border-box;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 16px;
    transition: all 0.3s ease;

    img {
        width: 32px;
        height: 32px;
        margin-right: 12px;
        transition: margin 0.3s ease;
    }

    span {
        color: #fff;
        font-size: 18px;
        font-weight: 600;
        transition: all 0.3s ease;
        white-space: nowrap;
    }
}

/* 会话列表区域 */
.conversations {
    padding: 0 8px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;

    &::-webkit-scrollbar {
        width: 6px;
    }

    &::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
    }
}

/* 样式覆盖 */
:global(.ant-conversations .ant-conversations-item .ant-conversations-label) {
    color: #fff;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.3s ease;
}

:global(.ant-conversations .ant-conversations-item-active .ant-conversations-label) {
    color: #cdefd1;
}

:global(.ant-conversations .ant-conversations-item) {
    position: relative;
    transition: all 0.3s ease;
}

/* 新建会话按钮 */
.addBtn {
    margin: 0 12px 16px;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;

    &:hover {
        background: rgba(255, 255, 255, 0.2) !important;
        transform: translateY(-1px);
    }

    .btnText {
        margin-left: 8px;
    }
}

/* 收起展开按钮 */
.collapseBtn {
    margin: 0 auto 16px;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
    transition: all 0.3s;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    &:hover {
        background: rgba(255, 255, 255, 0.2) !important;
        transform: scale(1.05);
    }

    .anticon {
        font-size: 16px;
        transition: transform 0.3s ease;
    }

    &.collapsed .anticon {
        transform: rotate(180deg);
    }

    /* 移动端适配 */
    @media screen and (max-width: 768px) {
        position: absolute;
        right: 8px;
        bottom: 16px;
        margin: 0;
        width: 36px;
        height: 36px;
        background: rgba(255, 255, 255, 0.15) !important;
    }
}

/* 移动端展开按钮 */
.expandBtn {
    display: none;
}

/* ================ 主内容区域 ================ */
.layoutMain {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    background: #f0f2f5;
    position: relative;
    height: 100vh;
    box-sizing: border-box;
    overflow: hidden;

    /* 移动端适配 */
    @media screen and (max-width: 768px) {
        padding: 8px;
        gap: 8px;
    }
}

/* 右侧顶栏 */
.header {
    display: flex;
    height: 56px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 0 24px;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 4px;

    /* 移动端适配 */
    @media screen and (max-width: 768px) {
        height: 48px;
        padding: 0 12px;
        border-radius: 8px;
        position: relative;
        z-index: 100;
    }
}

/* 用户信息区域 */
.userInfo {
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    padding: 4px 8px;
    border-radius: 24px;
    transition: all 0.3s;

    /* 改为仅移入触发背景变化，菜单由点击激活显示 */
    &:hover {
        background: rgba(0, 0, 0, 0.04);
    }

    /* 激活状态下显示下拉菜单 */
    &.active {
        background: rgba(0, 0, 0, 0.06);

        .dropdown {
            opacity: 1;
            transform: translateY(0);
            pointer-events: auto;
        }
    }

    .avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        margin-right: 8px;
        background: #e8f4ff;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #1677ff;
        font-size: 16px;
        font-weight: 600;
    }

    .username {
        font-size: 14px;
        font-weight: 500;
        color: rgba(0, 0, 0, 0.85);
        margin-right: 8px;

        /* 移动端适配 */
        @media screen and (max-width: 768px) {
            max-width: 100px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
    }

    .dropdown {
        position: absolute;
        top: calc(100% + 4px);
        right: 0;
        width: 120px;
        background: #fff;
        border-radius: 8px;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
        padding: 8px 0;
        opacity: 0;
        transform: translateY(8px);
        pointer-events: none;
        transition: all 0.2s ease;
        z-index: 1050;

        /* 移动端适配 */
        @media screen and (max-width: 768px) {
            right: 0;
            top: calc(100% + 4px);
        }

        .item {
            padding: 8px 16px;
            font-size: 14px;
            color: rgba(0, 0, 0, 0.65);
            display: flex;
            align-items: center;
            transition: all 0.2s;

            &:hover {
                background: rgba(0, 0, 0, 0.04);
                color: #1677ff;
            }

            .icon {
                margin-right: 8px;
                font-size: 14px;
            }
        }
    }
}

/* 主内容容器 */
.mainContent {
    flex: 1;
    display: flex;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: all 0.3s ease;
    column-gap: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);

    /* 移动端适配 */
    @media screen and (max-width: 768px) {
        border-radius: 8px;
        column-gap: 8px;
    }

    /* 聊天区域 */
    .chat {
        width: 50%;
        margin: 0 auto;
        transition: width 0.3s ease;
        position: relative;
        display: flex;
        flex-direction: column;
        padding: 24px;
        border-right: 1px solid rgba(0, 0, 0, 0.06);
    }

    /* PDF预览区域 */
    .pdfPreview {
        width: 50%;
        position: relative;
        background: #fff;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        transition: all 0.3s ease;
        overflow: hidden;


        >div {
            >div {
                scrollbar-width: 6px;
                scrollbar-color: rgba(0, 0, 0, 0.06) #fff;

                &::-webkit-scrollbar {
                    width: 6px;
                }

                &::-webkit-scrollbar-thumb {
                    background: rgba(0, 0, 0, 0.1);
                    border-radius: 3px;
                }
            }
        }

        .closeBtn {
            position: absolute;
            top: 16px;
            right: 16px;
            z-index: 10;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.9);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            border: none;
            opacity: 0.6;
            transition: all 0.3s ease;


            &:hover {
                opacity: 1;
                transform: scale(1.05);
                background: #fff;
            }

            .anticon {
                font-size: 14px;
                color: rgba(0, 0, 0, 0.65);
            }
        }
    }

    /* PDF隐藏时的样式 */
    &.withoutPdf {
        .chat {
            width: 100%;
        }

        .pdfPreview {
            width: 0;
            opacity: 0;
            visibility: hidden;
        }
    }
}

/* ================ 聊天内容区域 ================ */
.chatCon {
    height: calc(100% - 100px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.06) #fff;
    padding: 24px;
    // scroll-behavior: smooth;

    &::-webkit-scrollbar {
        width: 6px;
    }

    &::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.1);
        border-radius: 3px;
    }
}


/* ================ 消息气泡样式 ================ */
:global(.ant-bubble) {
    margin-bottom: 5px;
    animation: fadeIn 0.3s ease-out;

    :global(.ant-bubble-content) {
        background: #f5f7fa !important;
    }
}

:global(.ant-bubble-outlined) {
    border: 1px solid #f0f0f0;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}


:global(.ant-bubble .ant-bubble-content-outlined) {
    padding: 25px 12px 16px !important;
}

:global(.ant-bubble-end .ant-bubble-content-outlined) {
    padding: 0 10px !important;
}

:global(.ant-bubble-start) {
    margin-bottom: 15px !important;
}

:global(.ant-bubble .ant-bubble-content-filled) {
    /* background: #f5f7fa; */
}

/* ================ AI消息样式 ================ */
/* 思考过程区域 */
:global(.think-con) {
    background: #f6f7f9;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 0 0 16px 10px;
    font-size: 14px;
    color: #666;
    position: relative;
    border-left: 2px solid #e5e5e5;
    line-height: 26px;

    &::before {
        content: '思考过程';
        position: absolute;
        top: -21px;
        left: 4px;
        max-width: 100%;
        align-items: center;
        padding: 0 8px;
        border-radius: 8px 8px 8px 0;
        border: .5px solid rgba(183, 146, 72, .24);
        background: rgba(183, 146, 72, .12);
        color: #b79248;
        font-size: 12px;
        font-weight: 400;
        line-height: 20px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* 回答内容区域 */
:global(.answer-con) {
    background: #fff;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    margin-left: 8px;
    color: #252c38;
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    line-height: 28px;
}

/* ================ 参考文档样式 ================ */
:global(.source-con) {
    margin-top: 20px;
    border-top: 1px solid #f0f0f0;
    padding-top: 16px;
    display: flex;
    align-items: stretch;
    flex-direction: column;

    :global(.title) {
        align-self: flex-start;
        color: #252c38;
        font-size: 14px;
        font-weight: 700;
        line-height: 22px;
        display: block;
    }

    :global(.file-list) {
        position: relative;
        margin-top: 8px;
        display: grid;
        column-gap: 10px;
        row-gap: 8px;
        grid-template-columns: 1fr 1fr;
    }

    :global(.file-item) {
        min-width: 90%;
        width: 0;
        display: flex;
        padding: 15px;
        flex-direction: column;
        align-items: stretch;
        border-radius: 4px;
        background: #e9f2ff;
        cursor: pointer;
        transition: all 0.3s;

        &:hover {
            background: #f0f5ff;
        }

        :global(.file-t) {
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 3;
            overflow: hidden;
            color: #252c38;
            font-size: 14px;
            font-style: normal;
            font-weight: 400;
            line-height: 22px;
            min-height: 66px;

            :global(.tag) {
                display: inline-flex;
                width: 16px;
                height: 16px;
                margin-right: 3px;
                justify-content: center;
                align-items: center;
                border-radius: 4px;
                background: #97a3b4;
                cursor: pointer;
                color: #fff;
                font-size: 12px;
                font-style: normal;
                font-weight: 400;
                line-height: 10px;
            }
        }

        :global(.file-b) {
            margin-top: 4px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            color: #56647a;
            font-size: 12px;
            font-style: normal;
            font-weight: 400;
            line-height: 20px;

            :global(.title) {
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                flex-grow: 1;
                min-width: 0;
            }

            :global(.publish-date) {
                margin-left: 8px;
                flex-shrink: 0;
            }
        }
    }
}

/* 同时提供本地模块化类，用于直接在React组件中使用 */
.source-con {
    composes: source-con from global;
}

.file-list {
    composes: file-list from global;
}

.file-item {
    composes: file-item from global;
}

.file-t {
    composes: file-t from global;
}

.file-b {
    composes: file-b from global;
}

.tag {
    composes: tag from global;
}

.title {
    composes: title from global;
}

.publish-date {
    composes: publish-date from global;
}

/* ================ 提示词样式 ================ */
:global(.ant-prompts) {
    margin: 16px;

    :global(.ant-prompts-list) {
        overflow: hidden !important;
    }

    :global(.ant-prompts-item) {
        border-radius: 16px;
        transition: all 0.3s;

        &:hover {
            background: #f0f5ff;
            transform: translateY(-1px);
        }
    }
}

/* 提供本地模块化类 */
.ant-prompts {
    composes: ant-prompts from global;
}

.ant-prompts-list {
    composes: ant-prompts-list from global;
}

.ant-prompts-item {
    composes: ant-prompts-item from global;
}

/* ================ 动画效果 ================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================ 其他样式覆盖 ================ */
/* Ant Design 组件样式覆盖 */
:global(.ant-typography) {
    pre {
        border: none !important;
        border-left: 2px solid #e5e5e5 !important;
        padding-left: 13px;
        color: #8b8b8b;
        font-size: 13px;
        line-height: 26px;
        margin-bottom: 1em;
    }

    ul {
        padding-left: 2.2em;
        list-style-type: disc;
        margin: 0;
    }

    p {
        font-size: 14px;
        font-style: normal;
        font-weight: 400;
        line-height: 20px;
    }
}

/* 回答来源标签样式 */
:global(.answer_source_tag) {
    display: inline-flex;
    width: 16px;
    height: 16px;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    background: #e1e3e5;
    cursor: pointer;
    color: #56647a;
    font-size: 12px;
    font-style: normal;
    font-weight: 400;
    line-height: 10px;
    margin: 0 2px;

    &:hover {
        color: #fff;
        background: #1677ff;
    }
}

/* 本地类定义，用于直接在组件中引用 */
.answer_source_tag {
    composes: answer_source_tag from global;
}